lib/checkout: Optimize checkout by avoiding OstreeRepoFile recusion
authorColin Walters <walters@verbum.org>
Thu, 11 May 2017 01:40:50 +0000 (21:40 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Thu, 11 May 2017 14:15:54 +0000 (14:15 +0000)
commite6f17b949d8214049faca04d01d82bb28703cc77
tree26aaf122401c28003b40a43319df747e0337a23c
parent7896bcbe6595e4dd076a06a024d058193fa0f09c
lib/checkout: Optimize checkout by avoiding OstreeRepoFile recusion

Looking at `perf record ostree checkout`, some things stand out; e.g.:

```
+   27.63%     0.07%  ostree   libgio-2.0.so.0.5000.3      [.] g_file_enumerator_iterate
+   22.74%     0.28%  ostree   libostree-1.so.1.0.0        [.] ostree_repo_file_tree_query_child
+   13.74%     0.08%  ostree   libostree-1.so.1.0.0        [.] ot_variant_bsearch_str
```

The GIO abstractions are already fairly heavyweight, and `OstreeRepoFile` mallocs
a lot too.

Make things more efficient here by dropping the GIO bits for reading ostree data -
we just read from the variants directly and iterate over them.  The end result
here is that according to perf we go from ~40% of our time in the kernel to
~70%, and things like `g_file_enumerator_iterate()` drop entirely out of the
hot set.

Closes: #848
Approved by: jlebon
src/libostree/ostree-core-private.h
src/libostree/ostree-repo-checkout.c